<template>
  <div class="imgs flex flex-wrap">
    <div
      v-for="i in list"
      :key="i.name"
      class="img"
      :class="{ active: selected === i.url }"
      @click="handleSelect(i.url)"
    >
      <img :src="i.url" />
    </div>
  </div>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      default: () => []
    },
    selected: {
      type: String,
      default: ''
    }
  },
  methods: {
    handleSelect(i) {
      this.$emit('select', i)
    }
  }
}
</script>

<style lang="less" scoped>
.imgs {
  .img {
    position: relative;
    width: 48px;
    height: 48px;
    margin: 0 12px 12px 0;
    cursor: pointer;
    &.active {
      &::before {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        border: 14px solid @primary-color;
        border-left-color: transparent;
        border-bottom-color: transparent;
      }
      &::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        border: 3px solid @primary-color;
        z-index: 10;
      }
    }
    img {
      width: 100%;
      height: 100%;
    }
  }
}
</style>
